<template>
	<view>
		<view v-for="(item,index) in datalist" style="margin: 10rpx;">
			<CustomTextView 
				:nid="item.nID" 
				:title="item.title" 
				:isTop="item.isTop"
				:author="item.author" 
				:comments="item.comments" 
				:time="item.time"
				@click="onCustomViewClick(index)"
			>
			</CustomTextView>
		</view>
	</view>
</template>

<script>
	import CustomTextView from "@/components/cardViewText.vue"
	export default {
		components: {
			CustomTextView
		},
		data() {
			return {
				datalist: [
					{
						nID: "T15627",
						title: "我国成功发射新一代气象卫星 可实现分钟级暴雨预警",
						isTop: true,
						author: "新华社",
						comments: 1289,
						time: "2025.10.28"
					},
					{
						nID: "B4485",
						title: "《故宫文物修复技艺》纪录片开播 揭秘600年文物“重生”故事",
						isTop: false,
						author: "光明日报",
						comments: 856,
						time: "2025.10.27"
					},
					{
						nID: "T20200721",
						title: "教育部：中小学课后服务将新增科普、艺术等特色课程",
						isTop: true,
						author: "中国教育报",
						comments: 2103,
						time: "2025.10.28"
					},
					{
						nID: "B041124",
						title: "全国首批智能网联汽车开放道路测试里程突破100万公里",
						isTop: false,
						author: "经济日报",
						comments: 742,
						time: "2025.10.26"
					},
					{
						nID: "T20200",
						title: "研究发现：每天30分钟中等强度运动可降低老年痴呆风险",
						isTop: true,
						author: "健康时报",
						comments: 1537,
						time: "2025.10.27"
					},
					{
						nID: "C3698",
						title: "黄河三角洲湿地生态修复成效显著 越冬候鸟数量创新高",
						isTop: false,
						author: "中国环境报",
						comments: 629,
						time: "2025.10.26"
					}
				]
			}
		},
		methods: {
			onCustomViewClick(index) {
				console.log(`点击了第${index+1}条新闻：${this.datalist[index].title}`);
				// 可扩展：跳转至新闻详情页，如 uni.navigateTo({ url: `/pages/detail/detail?nid=${this.datalist[index].nID}` })
			}
		}
	}
</script>

<style>

</style>